<template>
	<view class="content">
		<view class="pageHeader">
			{{title}}记录
			<a class="generalBack" @click="backpage()" hover-class="none">
				<image src="/static/b-1.png" style="width: 18upx;height: 30upx;"></image>
			</a>
		</view>
		<view class="regoodbox">
			<scroll-view scroll-y="true" class="scroll-Y">
				<view v-if="recordList.length===0" class="empty">
					<image src="/static/empty.png" mode="widthFix"></image>
					<view class="empty-tips">
						暂无{{title}}记录
					</view>
				</view>
				<view v-for="(item, index) in recordList" :key="index" style="padding: 22upx 0;font-size: 28upx;margin-bottom:4upx;background-color: #fff;"
				 v-if="type==2">
					<view style="padding:0 30upx ;">
						<view style="display: flex;align-items: center;color: #666;">
							<image :src="item.avatarurl" style="width: 60upx;height: 60upx;margin-right: 20upx;border-radius: 50%;"></image>
							<view>
								<view>提现金额：{{item.price}}</view>
								<view>手续费：{{item.shouxufei}}</view>
								<view>提现时间：{{ item.addtime }}</view>
							</view>
						</view>
					</view>
				</view>
				<view v-for="(ritem, rindex) in recordList" :key="rindex" style="padding: 22upx 0;font-size: 28upx;margin-bottom:4upx;background-color: #fff;"
				 v-if="type==1">
					<view style="padding:0 30upx ;">
						<view style="display: flex;align-items: center;color: #666">
							<!-- <image :src="item.avatarurl" style="width: 60upx;height: 60upx;margin-right: 20upx;border-radius: 50%;"></image> -->
							<view>
								<view>充值账号：{{ritem.username}}</view>
								<view>充值金额：{{ritem.num}}</view>
								<view>充值状态：<text :style="{'color':ritem.status ==0?'':'#EC6104'}">{{ritem.status ==0?'充值失败':'充值成功'}}</text></view>
								<view>充值时间：{{ritem.addtime }}</view>
							</view>
						</view>
					</view>
				</view>
				<view class="loading">{{ loadingText }}</view>
			</scroll-view>
		</view>
	</view>
</template>
<script>
	import postAjax from '../../API/postAjax.js'
	export default {
		data() {
			return {
				userToken: '', // token	
				title: '',
				type: null,
				recordList: [

				],
				page: 1,
				loadingText: '加载中...'
			}
		},
		onLoad(options) {
			let that = this
			that.userToken = uni.getStorageSync('token')
			that.type = options.type
			options.type == 1 ? that.title = '充值' : that.title = '提现'
			that.get_record()
		},
		methods: {
			// 返回上一页
			backpage() {
				uni.navigateBack({
					delta: 1
				})
			},
			//滚动到底部

			onReachBottom: function() {
				this.getFileList();
			},
			recharge() {
				uni.navigateTo({
					url: 'recharge'
				})
			},

			get_record() {
				let that = this;
				uni.showNavigationBarLoading();
				let postdata = {
					token: that.userToken,
					m: 0,
					n: 20
				};
				let postUrl = ''
				that.type == 1 ? postUrl = 'Recharge/RecharecordRecord' : postUrl = 'Cash/WithdrawalRecord'
				// 我的订单列表
				let fileLog = [];
				postAjax(postUrl, postdata, function(data) {
					console.log(data.data)
					if (data.code == 0) {
						fileLog = data.data;

						if (fileLog.length > 0) {
							that.recordList = that.recordList.concat(fileLog);

							that.page++; //每触底一次 page +1
						} else {
							that.loadingText = '已加载全部';

						}

						if (that.recordList.length < 10) {
							that.loadingText = '';
						}

					} else {
						that.get_record()
					}
					uni.hideNavigationBarLoading();
				});
			}
		}
	}
</script>

<style>
	.generalBack {
		position: absolute;
		top: 40upx;
		left: 30upx;
		display: block;
	}

	.pstxt {
		position: relative;
	}

	.pstxt::before {
		content: '';
		display: block;
		width: 14upx;
		height: 14upx;
		background-color: #999;
		position: absolute;
		left: -24upx;
		top: 10upx;
		border-radius: 50%;
	}

	.pageHeader {
		position: relative;
		height: 64px;
		background-color: #1D84E8;
		line-height: 64px;
		text-align: center;
		font-size: 36upx;
		z-index: 999;
		color: #fff;
		padding-top: 20px;
	}

	.content {
		min-height: 100vh;
		background-color: #f5f5f5;
	}
	.empty {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100vh;
		padding-bottom: 100upx;
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		background: #fff;
	
	}
	
	.empty image {
		width:240upx;
		margin-top: 50upx;
	}
	
	.empty-tips {
		display: flex;
		font-size: 30upx;
		margin-top: 20upx;
		color: #666;
	
	}
</style>
